package com.wnhz.work.yz.adapter;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.wnhz.work.yz.R;
import com.wnhz.work.yz.bean.ItemChooseBean;

import java.util.List;

/**
 * Created by admin on 2016/12/10.
 */
public class ItemPopChooseAdapter extends BaseAdapter {
    private Context context;
    private List<ItemChooseBean> list;
    private LayoutInflater inflater;


    public ItemPopChooseAdapter(Context context, List<ItemChooseBean> list) {
        this.context = context;
        this.list = list;

    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        ViewHolder holder;
        if (convertView == null) {
            holder = new ViewHolder();
            convertView = LayoutInflater.from(context).inflate(R.layout.item_choose, null);
            holder.text = (TextView) convertView.findViewById(R.id.tv_item_choose);
            holder.line = convertView.findViewById(R.id.item_choose_bottom_line);
            holder.itemLayout = convertView.findViewById(R.id.root_item_choose);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }

        holder.text.setText(list.get(position).getTitles());
        boolean isItemClicked = list.get(position).isClicked();

        if (isItemClicked) {
            holder.line.setVisibility(View.VISIBLE);
            holder.text.setTextColor(Color.parseColor("#008c99"));
        } else {
            holder.line.setVisibility(View.GONE);
            holder.text.setTextColor(Color.parseColor("#666666"));
        }

        return convertView;
    }

    private class ViewHolder {
        TextView text;
        View itemLayout;
        View line;
    }
}

